//
//  HFCaptureSession.m
//  HocusFocus
//
//  Created by Juan Carlos Jimenez on 4/20/06.
//  Copyright 2008 Juan Carlos Jimenez. All rights reserved.
//

#import "HFCaptureSession.h"
#import "HFOrnament.h"

@implementation HFFocusArea

@synthesize rect;
@synthesize ornament;

- (BOOL)isValid
{
	return (self.rect.size.width > 0.1) && (self.rect.size.height > 0.1) && (ornament != nil);
}

@end

@implementation HFCaptureSession

@synthesize captureArea;
@synthesize currentOrnament;
@synthesize currentFocusArea;
@synthesize highlightedFocusArea;
@synthesize movingFocusArea;

- (id)init
{
	self = [super init];
    focusAreas = [[NSMutableArray alloc] init];
	return self;
}

- (void)dealloc
{
    [captureArea release];
	[focusAreas release];
	[currentOrnament release];
	[currentFocusArea release];
	[highlightedFocusArea release];
	[movingFocusArea release];
	[super dealloc];
}

- (void)reset
{
    self.captureArea = nil;
    [self.focusAreas removeAllObjects];
    self.currentFocusArea = nil;
    self.highlightedFocusArea = nil;
    self.movingFocusArea = nil;
}

- (BOOL)isDefiningCaptureArea
{
    return currentFocusArea == captureArea;
}

- (BOOL)hasValidCaptureArea
{
    return (self.captureArea != nil) && [self.captureArea isValid];
}

- (NSMutableArray *)focusAreas
{
    return focusAreas;
}

@end
